package br.com.neb.caronamanager.model.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBInitializer extends SQLiteOpenHelper{

	private static final String DB_NAME = "carona_db";
	public static final String TABLE_CARONA = "carona";
	private static final Integer DB_VERSION = 13;
	public static final String[] TABLE_CARONA_COLUMNS = new String[]{"_id","data","motorista","ida_volta"};
	
	public DBInitializer(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("create table " + TABLE_CARONA + " ("+TABLE_CARONA_COLUMNS[0]+" INTEGER PRIMARY KEY AUTOINCREMENT, "+TABLE_CARONA_COLUMNS[1]+" integer not null, "+TABLE_CARONA_COLUMNS[2]+" text not null, "+TABLE_CARONA_COLUMNS[3]+" integer not null default 0);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("drop table " + TABLE_CARONA +";");
		onCreate(db);
	}

}
